﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsPlatform.SportBusiness.ISportBusiness;
using SportsPlatform.Base;
using SportsPlatform.Query.SportBusiness.CompetitionAchievementInfo;
using Microsoft.AspNetCore.Mvc;
using SportsPlatform.Dto.SportBusiness.CompetitionAchievementInfo;
using SportsPlatform.Query.SportBusiness.AchievementOverPointInfo;
using SportsPlatform.Dto.SportBusiness.AchievementOverPointInfo;
using SportsPlatform.Query.SportBusiness.AchievementPunishmentInfo;
using SportsPlatform.Dto.SportBusiness.AchievementPunishmentInfo;
using SportsPlatform.SportBusiness.SportBusiness;
using SportsPlatform.Filters;
using SportsPlatform.Enums;

namespace SportsPlatform.Controllers
{
    /// <summary>
    /// 成绩管理
    /// </summary>

    [ActionAuthorization]
    [Route("api/[controller]/[action]")]
    public class CompetitionAchievementController : SportsPlatformControllerBase
    {
        /// <summary>
        /// 成绩信息管理接口
        /// </summary>
        private ICompetitionAchievementInfoService _competitionAchievementInfoService;

        /// <summary>
        /// 成绩过点记录接口
        /// </summary>
        private IAchievementOverPointInfoService _achievementOverPointInfoService;

        /// <summary>
        /// 成绩惩罚记录接口
        /// </summary>
        private IAchievementPunishmentInfoService _achievementPunishmentInfoService;
        /// <summary>
        /// 构造
        /// </summary>
        public CompetitionAchievementController(ICompetitionAchievementInfoService competitionAchievementInfoService, IAchievementOverPointInfoService achievementOverPointInfoService, IAchievementPunishmentInfoService achievementPunishmentInfoService)
        {
            _competitionAchievementInfoService = competitionAchievementInfoService;
            _achievementOverPointInfoService = achievementOverPointInfoService;
            _achievementPunishmentInfoService = achievementPunishmentInfoService;
        }


        #region 赛事成绩信息

        /// <summary>
        /// 新增赛事成绩信息
        /// </summary>
        /// <param name="addCompetitionAchievementInfoQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.AddEntity)]
        public async Task<BaseResultDto> AddCompetitionAchievementInfo([FromBody] AddCompetitionAchievementInfoQuery addCompetitionAchievementInfoQuery)
        {
            return await _competitionAchievementInfoService.AddCompetitionAchievementInfo(addCompetitionAchievementInfoQuery);
        }

        /// <summary>
        /// 赛事成绩信息同步
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> AchievementInfoSynchronization([FromBody] List<AchievementInfoSynchronizationQuery> query)
        {
            return await _competitionAchievementInfoService.AchievementInfoSynchronization(query);
        }

        /// <summary>
        /// 更新赛事成绩信息
        /// </summary>
        /// <param name="updateCompetitionAchievementInfoQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.EditEntity)]
        public async Task<BaseResultDto> UpdateCompetitionAchievementInfo([FromBody] UpdateCompetitionAchievementInfoQuery updateCompetitionAchievementInfoQuery)
        {
            return await _competitionAchievementInfoService.UpdateCompetitionAchievementInfo(updateCompetitionAchievementInfoQuery);
        }

        /// <summary>
        /// 分页获取赛事成绩信息
        /// </summary>
        /// <param name="getCompetitionAchievementInfoQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.QueryList)]
        public async Task<PagePagingDto<CompetitionAchievementInfoDto>> GetCompetitionAchievementInfo([FromBody] GetCompetitionAchievementInfoQuery getCompetitionAchievementInfoQuery)
        {
            return await _competitionAchievementInfoService.GetCompetitionAchievementInfo(getCompetitionAchievementInfoQuery);
        }

        /// <summary>
        /// 分页获取场次赛事成绩信息
        /// </summary>
        /// <param name="getEventsSessionCompetitionAchievementInfoPageQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.QueryList)]
        public async Task<PagePagingDto<EventsSessionCompetitionAchievementInfoDto>> GetEventsSessionCompetitionAchievementInfo([FromBody] GetEventsSessionCompetitionAchievementInfoPageQuery getEventsSessionCompetitionAchievementInfoPageQuery)
        {
            return await _competitionAchievementInfoService.GetEventsSessionCompetitionAchievementInfo(getEventsSessionCompetitionAchievementInfoPageQuery);
        }

        /// <summary>
        /// 下载分页获取场次赛事成绩信息Excel
        /// </summary>
        /// <param name="getEventsSessionCompetitionAchievementInfoPageQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.ExportData)]
        public async Task<ResultDto<DownloadEventsSessionCompetitionAchievementDto>> DownloadEventsSessionCompetitionAchievementExcel([FromBody] GetEventsSessionCompetitionAchievementInfoPageQuery getEventsSessionCompetitionAchievementInfoPageQuery)
        {
            return await _competitionAchievementInfoService.DownloadEventsSessionCompetitionAchievementExcel(getEventsSessionCompetitionAchievementInfoPageQuery);
        }

        /// <summary>
        /// 获取场次赛事成绩信息详情
        /// </summary>
        /// <param name="getEventsSessionCompetitionAchievementInfoQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.QueryEntity)]
        public async Task<ResultDto<EventsSessionCompetitionAchievementInfoDetailsDto>> GetEventsSessionCompetitionAchievementInfoDetails([FromBody] GetEventsSessionCompetitionAchievementInfoQuery getEventsSessionCompetitionAchievementInfoQuery)
        {
            return await _competitionAchievementInfoService.GetEventsSessionCompetitionAchievementInfoDetails(getEventsSessionCompetitionAchievementInfoQuery);
        }

        /// <summary>
        /// 根据赛事ID获取赛事比赛项目Id和名称
        /// 用于查询条件下拉框
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.QueryEntity)]
        public async Task<ResultListDto<GetCompetionProjectListByCompetionIdDto>> GetCompetionProjectListByCompetionId([FromBody] GetCompetionProjectListByCompetionIdQuery query)
        {
            return await _competitionAchievementInfoService.GetCompetionProjectListByCompetionId(query);
        }

        #endregion

        #region 赛事成绩过点记录信息

        /// <summary>
        /// 新增成绩过点记录信息
        /// </summary>
        /// <param name="addAchievementOverPointInfoQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.AddEntity)]
        public async Task<BaseResultDto> AddAchievementOverPointInfo([FromBody] AddAchievementOverPointInfoQuery addAchievementOverPointInfoQuery)
        {
            return await _achievementOverPointInfoService.AddAchievementOverPointInfo(addAchievementOverPointInfoQuery);
        }

        /// <summary>
        /// 分页获取成绩过点记录信息
        /// </summary>
        /// <param name="getAchievementOverPointInfoPageQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.QueryList)]
        public async Task<PagePagingDto<AchievementOverPointInfoDto>> GetAchievementOverPointInfo([FromBody] GetAchievementOverPointInfoPageQuery getAchievementOverPointInfoPageQuery)
        {
            return await _achievementOverPointInfoService.GetAchievementOverPointInfo(getAchievementOverPointInfoPageQuery);
        }

        /// <summary>
        /// 更新成绩过点记录是否有效
        /// </summary>
        /// <param name="updateAchievementOverPointInfoIsValidQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.EditEntity)]
        public async Task<BaseResultDto> UpdateAchievementOverPointInfoIsValid([FromBody] UpdateAchievementOverPointInfoIsValidQuery updateAchievementOverPointInfoIsValidQuery)
        {
            return await _achievementOverPointInfoService.UpdateAchievementOverPointInfoIsValid(updateAchievementOverPointInfoIsValidQuery);
        }

        /// <summary>
        /// 成绩过点记录信息同步
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> OverPointInfoSynchronization([FromBody] List<OverPointInfoSynchronizationQuery> query)
        {
            return await _achievementOverPointInfoService.OverPointInfoSynchronization(query);
        }

        #endregion

        #region 赛事成绩惩罚记录信息

        /// <summary>
        /// 新增成绩惩罚记录信息
        /// </summary>
        /// <param name="addAchievementPunishmentInfoQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.AddEntity)]
        public async Task<BaseResultDto> AddAchievementPunishmentInfo([FromBody] AddAchievementPunishmentInfoQuery addAchievementPunishmentInfoQuery)
        {
            return await _achievementPunishmentInfoService.AddAchievementPunishmentInfo(addAchievementPunishmentInfoQuery);
        }

        /// <summary>
        /// 分页获取赛事成绩惩罚记录信息
        /// </summary>
        /// <param name="getAchievementPunishmentInfoPageQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.QueryList)]
        public async Task<PagePagingDto<AchievementPunishmentInfoDto>> GetAchievementPunishmentInfo([FromBody] GetAchievementPunishmentInfoPageQuery getAchievementPunishmentInfoPageQuery)
        {
            return await _achievementPunishmentInfoService.GetAchievementPunishmentInfo(getAchievementPunishmentInfoPageQuery);
        }

        /// <summary>
        /// 更新成绩惩罚信息撤销状态
        /// </summary>
        /// <param name="updateAchievementPunishmentInfoRevokeQuery"></param>
        /// <returns></returns>
        [HttpPost]
        [Log(OperationType.EditEntityState)]
        public async Task<BaseResultDto> UpdateAchievementPunishmentInfoRevoke([FromBody] UpdateAchievementPunishmentInfoRevokeQuery updateAchievementPunishmentInfoRevokeQuery)
        {
            return await _achievementPunishmentInfoService.UpdateAchievementPunishmentInfoRevoke(updateAchievementPunishmentInfoRevokeQuery);
        }

        /// <summary>
        /// 成绩惩罚信息同步
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> PunishmentInfoSynchronization([FromBody] List<PunishmentInfoSynchronizationQuery> query)
        {
            return await _achievementPunishmentInfoService.PunishmentInfoSynchronization(query);
        }

        #endregion
    }
}
